<template>
  <div class="account">
    <router-view></router-view>
    <!--头部-->
    <div class="account-header">
      <div class="account-header-child">
        <!--上传图片-->
        <div class="account-box">
          <div class="account-box-file">
            <router-link to="/account/myselfData">
              <div class="box">
                <label>
                  <img :src="dataUrl">
                    <div id="imgEdit">
                      <img :src="imgEdit">
                    </div>
                </label>
                <div id="myname">
                  <p>name</p>
                  <p>wangde@.qq.com</p>
                </div>
              </div>
            </router-link>
          </div>
        </div>
        <!--右侧展示信息-->
        <div class="account-right">
          <h2 class="h2">高级版<a id="textSmall">套餐</a></h2>
          <!--右侧块元素-->
          <section class="account-content">
            <div class="content-box1">
              <!--流量块-->
              <div class="flow-list">
                <p class="flow-list-p">流量:
                  <span class="flowa"><b>{{flow.useHow}}</b>G/{{flow.allHow}}G</span>
                  <span class="see">
                    <router-link to="/account/seeTraffic">查看</router-link>
                  </span>
                </p>
                <p class="bar">
                  <span :style="widths"></span>
                </p>
              </div>
              <!--设备管理块-->
              <div class="equipment">
                <p>设备:
                  <span class="flowa"><b>2</b>台/3台</span>
                  <span class="see">
                    <router-link to="/account/manage">管理</router-link>
                  </span>
                </p>
              </div>
              <!--有效期块-->
              <div class="expiryDate">
                <p>有效期:<span class="flowa">{{overTime}}</span></p>
              </div>
            </div>
          </section>
        </div>
      </div>
    </div>
    <!--穿云令-->
    <div class="oven-me">
      <h2 class="h2">我的穿云令</h2>
      <p class="exchangeRecord"><i>兑换列表：</i><router-link to="/account/exchangeRecord">查看记录</router-link></p>
      <div class="my-oven">
        <div class="my-order">
          <div v-for="order in orders">
            <span>{{order.orderNumber}}</span>
            <span><button @click="exchange(order)">{{order.orderText}}</button></span>
            <!--兑换隐藏页面-->
            <div v-show="order.no4">
              <div class="hide-page" v-show="hidePage.hide1" @click="close"></div>
              <div class="exchange-box" id="exchange-box" v-show="hidePage.hide1">
                <div class="exchange-box-text">
                  <div class="exchange-content">
                    <h4>套餐详情</h4>
                    <div class="exchange-list" v-for="order2 in order.Packages">
                      <div>
                        <h6>{{order2.name}}</h6>
                      </div>
                      <div>
                        <p>穿云令:{{order2.id}}</p>
                      </div>
                      <div v-for="list12 in order2.lists2">
                        <p>{{list12.text}}</p>
                      </div>
                    </div>
                    <div class="prompt">
                      <p><b>注意</b>:当当前使用套餐与要兑换套餐一致时，点击兑换将延长套餐时间,若不一致将覆盖原套餐</p>
                    </div>
                    <div class="exchange-button">
                      <button @click="exchangeD">确认兑换</button>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="oven-rule">
        <p>使用规则：</p>
        <p>1.穿云令具有传播性，你可以自己使用，也可以二次销售</p>
        <p>2.复制兑换码，点击兑换</p>
      </div>
    </div>
    <!--邀请好友-->
    <div class="invitingFriends">
      <h2 class="h2">邀请好友</h2>
      <p>为了提供更优质的VPN服务，所有注册用户需输入好友邀请码才能注册为会员。你可将下面的邀请码发送给您的好友！</p>
      <div class="invitingFriendsCode">
        <span id="contents" ref="contents">{{invitingCode}}</span>
        <span><button @click="jsCopy()">复制</button></span>
      </div>
    </div>
    <footer-one></footer-one>
  </div>
</template>
<script>
  import edit from '../assets/edit.png'
  import safa from '../assets/bg_safe.png'

//  import seeTraffic from '../components/firmware/seeTraffic.vue'/**/
  import FileImg from '../components/firmware/file.vue'
  import FooterOne from '../components/firmware/footer.vue'
  export default{
      name:'account',
      data(){
          return{
              dataUrl:localStorage.dataText,
              imgEdit:edit,
              hidePage:{
                  hide1:false
              },
              exchangeDispaly:{
                  no4:false
              },
              flow:{
                  allHow:'1204',
                  useHow:'500'
              },
              widths:{
                  width:''
              },
              overTime:'2018/9/7',
              orders:[
                {
                  orderNumber:'12345655555555',
                  orderText:'兑换',
                  no4:false,
                  Packages:[
                    {
                      name:'pro套餐',
                      id:'12345655555555',
                      lists2:[
                        {
                          text:'-每月不限流量'
                        },
                        {
                          text:'-支持同时在线：2台终端'
                        },
                        {
                          text:'-独享带宽3M/s'
                        },
                        {
                          text:'-全球节点'
                        },
                        {
                          text:'赠送4个-VPN激活码，可出售'
                        }
                      ]

                    }
                  ]
                },
                {
                  orderNumber:'123456444444444',
                  orderText:'兑换',
                  no4:false,
                  Packages:[
                    {
                      name:'my套餐',
                      id:'123456444444444',
                      lists2:[
                        {
                          text:'-每月300G流量'
                        },
                        {
                          text:'-支持同时在线：2台终端'
                        },
                        {
                          text:'-独享带宽3M/s'
                        },
                        {
                          text:'-全球节点'
                        },
                        {
                          text:'赠送2个-VPN激活码，可出售'
                        }
                      ]

                    }
                  ]
                }
              ],
              invitingCode:'85926548751485'

            }
      },
    components:{FileImg,FooterOne},
    mounted(){
          this.widths.width =  ((this.flow.useHow /this.flow.allHow) * 500)+'px';
    },
    methods:{
        jsCopy:function () {
            console.log('fuzhi')
          let _self = this;
          var obj = _self.$refs.contents; //获取dom实例
          console.log(obj);
//          document.execCommand("Copy")
//          obj.cloneNode();
          obj.document.execCommand("Copy") //复制按钮
        },
        exchange:function(order){
          let _self = this;
          _self.$set(_self.hidePage,'hide1',true);
          _self.$set(_self.exchangeDispaly,'no4',true);
          _self.orders.forEach(function (el) {
            if(el == order){
                el.no4 = true;
            }else {
                el.no4 = false;
            }
          })
        },
        //确认兑换
        exchangeD:function () {
            let _self = this;
          setTimeout(function () {
              console.log('兑换')
            _self.close();
          },1000)
        },
        //关闭弹出框
        close:function () {
          let _self = this;
          _self.$set(_self.hidePage,'hide1',false);
        }
    },
    watch:{
        dataUrl(newVal){
            if(newVal == null){
                this.dataUrl = safa;
            }else {
              this.dataUrl = localStorage.dataText;
            }
        }
    }
  }
</script>
<style scoped>
  p ,div, h1{
    padding: 0;
    margin: 0;
  }
  b{
    font-size: 1.8rem;
    color:#FF7A3F ;
  }
  a{
    text-decoration: none;
    color: #FF7A3F;
  }
  .h2{
    font-size: 1.8rem;
    font-weight: 100;
  }
  #textSmall{
    font-size:1.1rem;
    font-weight: 200;
  }
  .account{
    min-width: 1200px;
  }
  .account-header{
    background-color:#F5F5F5 ;
    width: 100%;

  }
  .account-header-child{
    max-width: 960px;
    margin: auto;
    width: 100%;
  }

  .account-header div{
    display: inline-block;
    padding: 3rem 0;
    margin: auto;
  }
  .account-box{
    width: 40%;
    vertical-align: middle;

  }
  .account-box div{

  }
  .account-box-file{

  }
  /*头像区样式*/
  .box div{
    text-align: center;
  }
  .box label{
    display: block;
    height: 180px;
    width: 180px;
    border: 1px solid rgba(0,0,0,0.2);
    border-radius: 50%;
    margin: auto;
    position: relative;
    z-index: 1;
  }
  .box label img{
    border-radius: 50%;
    height: 100%;
    width: 100%;
    overflow: hidden;
    display: block;
  }
  .box input{
    display: none;
  }
  #myname{
    padding: 0;
  }
  #imgEdit{
    position: absolute;
    z-index: 100;
    right: 20px;
    bottom: 15px;
    padding: 0;
  }

  .account-right{
    width: 50%;
    text-align: left;
    vertical-align: middle;
  }
  .account-right h2{
    color:#FF7A3F ;
  }
  .account-content div{
    display: block;
    margin: 0;
    padding: 0 ;
  }
  .account-content{
    height: 300px;
    width: 100%;
    background-color: #ffffff;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
    border-radius: 5px;

  }
  .content-box1{
    margin: auto;
    width: 100%;
    height: 100%;
  }
  .content-box1 div{
    width: 80%;
    margin: auto;
  }
  .flowa{
    padding-left: 10px;
  }

  /*流量*/
  .flow-list{
    /*height: 150px;*/
    line-height: 75px;
    border-bottom: 1px solid rgba(0,0,0,0.3);
    padding: 10px 0;
  }
  .flow-list p{
    margin: 0;
    padding: 0;
  }
  .flow-list .flow-list-p span{
    display: inline-block;
  }
  .see{
    text-align: right;
    float: right;
    /*padding-right: 20px;*/
  }
  .see a:hover{
    cursor: pointer;
    color: #FF7A3F;
  }
  .flow-list .bar{
    margin-bottom: 20px;
    /*width: 300px;*/
    height: 8px;
    border: 1px solid #bbbbbb;
    border-radius: 5px;
  }
  .flow-list .bar span{
    background-color: orangered;
    height: 8px;
    display: block;
    border-radius: 5px;
  }
  /*设备*/
  .equipment{
    line-height:80px;
    border-bottom: 1px solid rgba(0,0,0,0.3);
  }
  .equipment p{
    margin: 0;
    /*padding: 15px 0;*/
  }
  /*有效期*/
  .expiryDate{
    line-height: 60px;
  }
  .expiryDate p{
    margin: 0;
    padding: 0;
  }
  /*我的穿云令列表*/
  .oven-me{
    max-width: 960px;
    margin: 90px auto 90px;
  }
  .oven-me h2{
    padding: 50px 0;
  }
  .oven-me p{
    /*text-align: left;*/
    margin: auto;
  }
  .my-oven{
    /*height: 400px;*/
    width: 90%;
    background-color: #F5F5F5;
    margin: auto;
  }
  .my-order{
    padding: 3rem 0;

  }
  .my-order div{
    padding: 25px 0;
  }
  .my-order div span{
    display: inline-block;
    width: 40%;
    /*margin: auto;*/
    text-align: center;
  }
  .my-order button{
    border: 1px solid #FF7A3F;
    color: #FF7A3F;
    background-color: #F5F5F5;
    border-radius: 30px;
    height: 30px;
    width: 60px;
    outline: none;
    cursor: pointer;
  }
  .my-order button:hover{
    color: #ffffff;
    background-color:#FF7A3F;
  }
  /*规则*/
  .oven-rule{
    width: 90%;
    padding: 50px 0;
    margin: auto;
  }
  .oven-rule p{
    line-height: 30px;
  }
  .exchangeRecord{
    width: 90%;
    text-align: right;
  }

  /*邀请码*/
  .invitingFriends{
    max-width: 960px;
    margin:  10px auto 60px;
  }
  .invitingFriends h2{
   padding: 3rem 0;
  }
  .invitingFriends p{
    text-indent: 30px;
    width: 80%;
    margin: auto;
    text-align: left;
  }
  .invitingFriendsCode{
    padding: 50px 0;
  }
  .invitingFriendsCode span{
    display: inline-block;
    width: 15%;
    text-align: center;
  }
  .invitingFriendsCode button{
    border: 1px solid #FF7A3F;
    color: #FF7A3F;
    background-color: #F5F5F5;
    border-radius: 30px;
    height: 30px;
    width: 60px;
    outline: none;
    cursor: pointer;
  }
  .invitingFriendsCode button:hover{
    color: #ffffff;
    background-color:#FF7A3F;
  }
  /*弹出页面*/
  .hide-page{
    background: rgba(0, 0, 0, 0.35);
    color: rgb(232, 61, 58);
    white-space: pre;
    font-family: Menlo, Consolas, monospace;
    font-size: 13px;
    position: fixed;
    z-index: 1;
    padding: 10px;
    left: 0px;
    right: 0px;
    top: 0px;
    bottom: 0px;
    overflow: auto;
  }
  /*白的弹框*/
  #exchange-box{
    padding:0;
  }
  .exchange-box{
    position: fixed;
    top:50%;
    left: 50%;
    height: auto;
    width: 450px;
    margin-left: -220px;
    margin-top: -300px;
    z-index:9999;
    overflow: hidden;
    font-size: 0;
    background-color: #ffffff;
    border-radius: 5px;

  }
  .exchange-box div{
    padding: 0;
  }
  .exchange-box-text{
    display: table;
    vertical-align: middle;
    margin: 0 auto;
    width: 100%;
  }
  .exchange-content{
    display: table-cell;
    vertical-align: middle;
    font-size: 1.0rem;
    height: 100%;

  }
  .exchange-content h4{
    font-size: 1.1rem;
    font-weight: 100;
    padding: 15px 0 5px;
  }
  .exchange-content .exchange-list{
    height: auto;
    border: 1px solid #f5f5f5;
    padding-bottom: 30px;
    border-radius: 10px;
    background-color: #F6F4F2;
    width: 80%;
    margin: auto;
    text-align: left;
    text-indent: 30px;
  }
  .exchange-content .exchange-list h6{
    margin: 0;
    padding: 10px 0;
    /*text-align: left;*/
    background-color: #FF7A3F;
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 100;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
  }
  .exchange-content .prompt{
    width: 80%;
    margin: auto;
    padding:5px 0 15px ;
  }
  .exchange-content .prompt p{
    text-align: left;
    color: #FF7A3F;
  }
  .exchange-content .exchange-list p{
    padding: 18px 0 0;
    /*text-indent: 40px;*/
  }
  .exchange-content .exchange-button{
    /*height: 10%;*/
    padding: 15px 0 40px;
  }
  .exchange-content .exchange-button button{
    height: 38px;
    width: 140px;
    border: 0;
    outline: none;
    color: #ffffff;
    background-color:#FF7A3F ;
    border-radius: 8px;
  }
  .exchange-content .exchange-button button:hover{
    background-color: #FF5B2E;
    cursor: pointer;
  }

</style>
